package com.ftg.wymall.admin.mapper;

import com.ftg.wymall.admin.entity.UmsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 后台用户表 Mapper 接口
 * </p>
 *
 * @author kangjx
 * @since 2023-10-20
 */
@Mapper
public interface UmsAdminMapper extends BaseMapper<UmsAdmin> {

    /**
     * 当用户登陆的时候用来更新登陆时间
     * @param id   用户id
     * @return  true
     */
    @Update("update ums_admin set login_time = now() where id = #{id}")
    boolean updateLoginTime(@Param("id") Long id);

    /**
     * 修改头像
     * @param id   用户id
     * @param url  头像url
     * @return  true
     */
    @Update("update ums_admin set icon = #{url} where id = #{id}")
    boolean modifyAvatar(@Param("id")Long id, @Param("url") String url);

    /**
     * 修改用户信息
     * @param user  用户信息
     * @return  true
     */
    Boolean modifyUmsAdminWithNonNull(UmsAdmin user);
}
